import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

const routes = [
  {
    path: "/login",
    name: "login",
    component: () => import("@/views/login"),
  },
  {
    path: "/",
    // name: "layout", //有默认子路由的话，父路由可以不用设置name
    component: () => import("@/views/layout"),
    children: [
      {
        path: "", //path为空表示默认渲染该页面
        name: "home",
        component: () => import("@/views/home"),
      },
      {
        path: "/Qa",
        name: "Qa",
        component: () => import("@/views/Qa"),
      },
      {
        path: "/video",
        name: "video",
        component: () => import("@/views/video"),
      },
      {
        path: "/my",
        name: "my",
        component: () => import("@/views/my"),
      },
    ],
  },
  {
    path: "/search",
    name: "search",
    component: () => import("@/views/search"),
  },
  {
    path: "/article/:articleId",
    name: "article",
    component: () => import("@/views/article"),
    props: true,
  },
  {
    path: "/user/profile",
    name: "user-profile",
    component: () => import("@/views/user-profile"),
    props: true,
  },
];

const router = new VueRouter({
  routes,
});

export default router;
